package com.karson.front.consumer;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import com.karson.common.config.rabbitmq.RabbitConfig;
import com.karson.common.dto.rabbitmq.TagStatusMessageDTO;
import com.karson.service.service.AlbumTagsService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author ZKS
 */
@Component
public class TagConsumer {
    @Autowired
    private AlbumTagsService albumTagService;


    @RabbitListener(queues = RabbitConfig.QUEUE_TAG_STATUS)
    public void handleStatus(String message){
        JSON json = JSONUtil.parse(message);
        TagStatusMessageDTO messageDTO = json.toBean(TagStatusMessageDTO.class);
        albumTagService.flushTagStatus(messageDTO);
    }


}
